//
//  ZCMeSquareButton.m
//  ZCBaiSi
//
//  Created by zc on 16/7/18.
//  Copyright © 2016年 zc. All rights reserved.
//

#import "ZCMeSquareButton.h"
#import <UIButton+WebCache.h>
@implementation ZCMeSquareButton

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.imageView.zc_y = self.zc_height * 0.15;
    self.imageView.zc_height = self.zc_height * 0.5;
    self.imageView.zc_width = self.imageView.zc_height;
    self.imageView.zc_centerX = self.zc_width * 0.5;
    self.titleLabel.zc_x = 0;
    self.titleLabel.zc_y = self.imageView.zc_bottom;
    self.titleLabel.zc_width = self.zc_width;
    self.titleLabel.zc_height = self.zc_height - self.titleLabel.zc_y;
}

- (void)setSquare:(ZCMeSquare *)square{
    _square = square;
    [self setTitle:square.name forState:UIControlStateNormal];
    [self sd_setImageWithURL:[NSURL URLWithString:square.icon] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"setup-head-default"]];
    
}

@end
